|
if your app would need to create/modify the XML file, it would not be wise to put such data file in the EXE's folder as:
1. the folder is shared by all users;
2. the folder might be write-protected.
When in doubt, the better approach is to use one of the official folders as returned by Environment.GetFolderPath() .
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I never put settings files in an application directory; I put them in a settings directory -- that's what they're for.
For instance C:\Documents and Settings\All Users that way they can even be shared among different applications as well as different users.
|
|
|
|
|
Hi All,
I want to show some ongoing even on in the mean time when the connection is being opened.
When I tried to show the LABEL or tried to MODIFY the text of button, it doesn't happen till
the conn is opened. After conn opens - then only the text is changed as 'Connecting...' ,
which I want to show in the mean time when connection is getting opened.
Any help..?
Thanks and regards
- Ajay K
|
|
|
|
|
It sounds like you are trying to update the label and open the connection on the same thread. If you need them both appear to be happening at the same time, you should move the connection handling onto a background thread.
|
|
|
|
|
the following sequence could suffice:
label1.Text="Going to connect";
label1.Refresh();
Connect();
label1.Text="Connected";
label1.Refresh();
however it is always better to delegate long-winding or possibly long-winding operations to another thread.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
But what if it doesn't connect? Then the "Connecting..." text is a lie and you've just lied to your trusting user; that's poor customer relations. Don't promise something that you can't deliver. Change the text to "Attempting to connect... this usually works... but some times it doesn't... and if it doesn't, then I'll be just as sad as you will be and we can cry together."
|
|
|
|
|
Hi all,
I want to use a dotnetnuke login code in a c# application and the data is store in MSSQL database.
I am new to it ?
Can anyone tell me how can i use it.
Thanks in advance.
|
|
|
|
|
You could try here[^].
I must get a clever new signature for 2011.
|
|
|
|
|
Hi all, I need to develop a progress bar in my web application which is in asp.net. This progress bar should see on screen while switching to new page of my application.
I have master page in which i have created diffrent menues.. like Audit,Manual,Update
on click of tht different pages will get disply.
so i want to disply progressbar on click of those menus
<td id="tdmnuPerfRating" valign="middle" align="center" style="width: 200px; height: 25px;
background-image: url(./images/grey_bg.jpg);" onmouseover="javascript:changecolor(this,'on');"
onmouseout="javascript:changecolor(this,'off');">
<asp:HyperLink ID="HyperLink3" runat="server" CssClass="CSMenu" Text="Performance Rating"
NavigateUrl="~/ViewAudit.aspx" />
</td>
<td align="center" valign="middle" style="width: 1px; height: 25px">
<div style="display: inherit;">
<img src="images/line_vertical.jpg" border="0" alt="Line" height="25px" /></div>
</td>
<td id="tdIssue" valign="middle" align="center" style="width: 200px; height: 25px;
background-image: url(./images/grey_bg.jpg);" onmouseover="javascript:changecolor(this,'on');"
onmouseout="javascript:changecolor(this,'off');">
<asp:HyperLink ID="HyperLink27" runat="server" CssClass="CSMenu" Text="Issues"
NavigateUrl="~/ViewIssues.aspx" />
</td>
|
|
|
|
|
Mugdha_Aditya wrote: I need to develop a progress bar in my web application which is in asp.net.
Then kindly post your question in the correct forum, i.e. ASP.NET.
I must get a clever new signature for 2011.
|
|
|
|
|
I have found a great library for polynomials here on code project
A C# Class for Complex Polynomials[^]
I just wondered how i would go about changing the ToString method to print out the polynomial in the form 2x^2 + 3x + 4 etc
I have tried to modify the for loop to go down instead of up but it doesnt come out correctly. I have also tried modifying other values yet it results in the index out of bounds error.
Any suggestions would be greatly appreciated!
Thanks in advance
|
|
|
|
|
Ryano121 wrote: I just wondered how i would go about changing the ToString method to print out the polynomial in the form 2x^2 + 3x + 4 etc
By overriding it's original implementation and providing their own. If you take a look at the source[^] file called "Complex.cs", you'll find that behaviour implemented starting on line 433;
433 public override string ToString()
434 {
435 if (this == Complex.Zero) return "0";
MSDN has a How To[^]-article on the subject
I are Troll
|
|
|
|
|
Thanks for the reply!
Thanks for info on overriding! However it also seems that in Polynomial.cs, the override of ToString presents the object in the format 4 + 3x + 2x^2 instead of the conventional 2x^2 + 3x + 4.
I was just wondering if there was a way of modifying the existing ToString in the Polynomial.cs class to get the string in this format. I think it may be something to do with the for loop however the modifications i have made so far have only resulted in index out of bounds exceptions being made
Thanks again
|
|
|
|
|
Ryano121 wrote: it doesnt come out correctly.
That tells me you did something wrong.
Ryano121 wrote: Any suggestions would be greatly appreciated!
Fix your mistake. And if you can't, provide more information so people here can help you.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sorry about that
Basically the Polynomial class has a Complex[] field that stores the coefficients of the equation. e.g 1,7,12 for x^2 + 7x + 12. The class has an overriden ToString method that gives a representation of what the equation is. However the given implementation given below provides 12 + 7x + x^2 instead of the conventional x^2 + 7x + 12 that i am looking for.
public override string ToString()
{
if (this.IsZero()) return "0";
else
{
string s = "";
for (int i = 0; i < Degree + 1; i++)
{
if (Coefficients[i] != Complex.Zero)
{
if (Coefficients[i] == Complex.I)
s += "i";
else if (Coefficients[i] != Complex.One)
{
if (Coefficients[i].IsReal() && Coefficients[i].Re > 0)
s += Coefficients[i].ToString();
else
s += "(" + Coefficients[i].ToString() + ")";
}
else if (i == 0)
s += 1;
if (i == 1)
s += "x";
else if (i > 1)
s += "x^" + i.ToString();
}
if (i < Degree && Coefficients[i + 1] != 0 && s.Length > 0)
s += " + ";
}
return s;
}
Or also here
http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=19446[^]
I have tried to modify the for loop to
for (int i = Degree -1; i >= 0; i--)
But that gives the + signs after the equation. I have also tried to modify other parts of the method yet it usually results in array index out of bounds exceptions.
Can anyone give me some pointers on how to modify the method to give the 'conventional' interpretation of equations?
Thanks again
|
|
|
|
|
|
OK, the problem is with the operator signs; it is caused by the non-ideal approach taken originally: there is an if statement trying to look at the next coefficient. It is bound to go wrong when traversing the array in the other direction. And it is plain wrong as is anyway, just imagine a few consecutive coefficients being zero.
The correct approach would implement this rule: each term needs a "+" sign if it hasn't a negative coefficient and isn't the first term in the output. Putting it like that, you don't need to look at other coefficients, you just keep one state variable telling you whether or not this is the first term to be seen.
In pseudo-code:
bool firstTerm=true;
foreach(term in polynomial) {
if (coef==0) skip;
if (!firstTerm && coef>0) output("+");
output(term);
firstTerm=false;
}
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I am using c# window application. I am trying to pass the value of variable from one form to other. But it is giving error:Can any one correct this? thanks in advance.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace WindowsApplication1
{
public partial class Form1 : System.Windows.Forms.Form
{
public string frm1;
Form2 f = new Form2();
private string stringOnForm1;
public Form1(string sTEXT)
{
InitializeComponent();
textBox1.Text = sTEXT;
}
private void Form1_Load(object sender, EventArgs e)
{
f.Show();
f.button2.Visible = false;
Random rand = new Random();
Color[] c = { Color.Green, Color.Red };
this.button1.BackColor = c[rand.Next(0, c.Length)];
this.button2.BackColor = c[rand.Next(0, c.Length)];
if (this.button1.BackColor == Color.Red && this.button2.BackColor != Color.Red)
{
f.button2.Visible = true;
f.s = "1 Message received";
f.s1 = "ur gas is being leaked";
}
else if (this.button2.BackColor == Color.Red && this.button1.BackColor != Color.Red)
{
f.button2.Visible = true;
f.s = "1 Message received";
f.s1 = "ur electric is being leaked";
}
else if (this.button1.BackColor == Color.Red && this.button2.BackColor == Color.Red)
{
f.button2.Visible = true;
f.s = "2 Messages received";
f.s1 = "ur electric and gas is being leaked";
}
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
} }
Error:
No overload for method 'Form1' takes '0' arguments
|
|
|
|
|
Either try adding the default constructor back to your source code:
public Form1() {
InitializeComponent();
}
or modify the creation of the Form1 to have a string parameter for parameter sTEXT. For example:
... a = new Form1("SomeText");
|
|
|
|
|
What the message says is this: (for some reason, not sure which) your app needs a Form1 constructor without parameters, and you only have a single constructor, one with a string parameter.
I have three pieces of advice for you:
1.
learn to use all available information; when using a debug build, a compile-time error as well as a run-time exception provides you with file name or class name, and line number information. So you can easily figure out where it is unhappy. The problem may exist at that very location, or it gets detected at that location but is located elsewhere.
In this case I bet it is pointing to something like Application.Run(new Form1()); in perhaps a file called Program.cs
2.
learn to properly post a question. Your problem description (what it does, what you hope it would do, what your overall goal is) is not so good (you may have noticed most of your posts so far have been down-voted by one or more people). Your usage of PRE tags is fine, however we have seen 10 generations of your code already; and it badly needs a clean up, so please remove all empty handlers, all commented code, all redundant empty lines; then show only the relevant part of it. Which you probably haven't this time, if my hunch is right.
3.
Stop your hip-hop experiments for a while; choose, buy and study an introductory book on C# and learn how to program in a structured way. It will teach you many things including the use of meaningful names (not: Form1, Form2, f), object orientation, proper code design, etc.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I realise this sounds a bit pathetic, but I have developed a workaround for a weakness in the pictureBox class, and I will publish it as an article on CodeProject. However I haven't yet upgraded from VC2005 (as a freelancer I am having trouble getting work in these straightened times and don't reall want to shell out for VS2010 just at the moment). Before I publish I would like to check whether the problem has been solved in later versions of .NET. I have a test program all ready. If someone with VS2010 could spare half an hour to run the test it would save me wasting my and everyone else's time on an unecessary article.
Dave
|
|
|
|
|
VS2010 comes in Express versions http://www.microsoft.com/express/Downloads/[^] - that way you can evaluate your software at no charge to you...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Doh!. Thanks OriginalGriff. I didn't even realise they did a free Express version. That's done the trick. What an idiot!!
Dave
|
|
|
|
|
Welcome!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
You don't need Visual Studio to compile against .net anyway. I recommend learning to make do without it.
|
|
|
|